home *** CD-ROM | disk | FTP | other *** search
- package Forms
- {
- import flash.display.DisplayObject;
- import flash.display.MovieClip;
- import flash.display.SimpleButton;
- import flash.events.Event;
- import flash.events.MouseEvent;
- import flash.text.TextField;
-
- [Embed(source="/_assets/assets.swf", symbol="Forms.ProfileForm")]
- public class ProfileForm extends CluelessBaseForm
- {
-
-
- internal var slotnumberIndex:int;
-
- public var _mcModelBackground:MovieClip;
-
- internal var _iCurrentProfileIndex:int;
-
- internal var _bCurrentProfile:Boolean;
-
- public var _bCreate:SimpleButton;
-
- public var _slot0:ProfileDisplay;
-
- public var _mcModels:MovieClip;
-
- public var _slot1:ProfileDisplay;
-
- public var _bDeleteSlot0:SimpleButton;
-
- public var _bDown:ArrowTriangle;
-
- public var _tfDeleteSlot0:TextField;
-
- public var _bDeleteSlot1:SimpleButton;
-
- public var _tfDeleteSlot1:TextField;
-
- public var _bBack:SimpleButton;
-
- internal var _aFilters:Array;
-
- internal var _componentscroller:ComponentScroller;
-
- public var _bUp:ArrowTriangle;
-
- public function ProfileForm()
- {
- var _loc1_:MovieClip = null;
- _componentscroller = new ComponentScroller();
- super();
- _componentscroller.setScrollButtons(_bUp,_bDown,this);
- _componentscroller.BackgroundItems = 0;
- _bCurrentProfile = false;
- _componentscroller.addEventListener(ComponentScrollerEvent.COMPONENT_SCROLLER_UPDATED,onUpdated,false,0,true);
- _bDeleteSlot0.addEventListener(MouseEvent.CLICK,onDeleteSlot,false,0,true);
- _bDeleteSlot1.addEventListener(MouseEvent.CLICK,onDeleteSlot,false,0,true);
- _aFilters = _slot0.filters;
- _loc1_ = new MovieClip();
- swapItem(_loc1_,_slot0);
- _componentscroller.addSlot(_loc1_);
- _loc1_ = new MovieClip();
- swapItem(_loc1_,_slot1);
- _componentscroller.addSlot(_loc1_);
- setBackButton(_bBack);
- installMouseOverSound(_bBack);
- _bCreate.addEventListener(MouseEvent.CLICK,onCreateClicked,false,0,true);
- rebuildList();
- _tfDeleteSlot0.mouseEnabled = false;
- _tfDeleteSlot1.mouseEnabled = false;
- }
-
- override public function onFocus() : void
- {
- var _loc1_:Array = null;
- var _loc2_:int = 0;
- var _loc3_:ProfileDisplay = null;
- super.onFocus();
- _loc1_ = buildProfileLists();
- _loc2_ = _iCurrentProfileIndex - 1;
- _loc3_ = null;
- trace("Num profiles = " + _loc1_.length);
- if(_loc1_.length > 1 && _loc2_ == _loc1_.length - 1)
- {
- _loc2_--;
- }
- if(_loc2_ >= 0)
- {
- _componentscroller.setItems(_loc1_,_loc2_);
- }
- else
- {
- _componentscroller.setItems(_loc1_);
- }
- _componentscroller.update();
- if(_bCurrentProfile == true && _loc1_.length > 0)
- {
- if(_loc1_.length == 1 || slotnumberIndex == 0)
- {
- _loc3_ = _componentscroller.getItemAtSlot(0) as ProfileDisplay;
- }
- else
- {
- _loc3_ = _componentscroller.getItemAtSlot(1) as ProfileDisplay;
- }
- Profile.CurrentProfile = Profile.getProfile(_loc3_.ProfileName);
- Storage.getInstance().saveProfiles();
- }
- }
-
- protected function onMouseLeave(param1:MouseEvent) : void
- {
- var _loc2_:MovieClip = null;
- _loc2_ = param1.currentTarget as MovieClip;
- _loc2_.filters = null;
- }
-
- protected function onMouseEnter(param1:MouseEvent) : void
- {
- var _loc2_:MovieClip = null;
- _loc2_ = param1.currentTarget as MovieClip;
- _loc2_.filters = _aFilters;
- }
-
- protected function buildProfileLists() : Array
- {
- var _loc1_:Array = null;
- var _loc2_:Profile = null;
- var _loc3_:int = 0;
- var _loc4_:ProfileDisplay = null;
- _loc1_ = new Array();
- _loc3_ = 0;
- _iCurrentProfileIndex = 0;
- for each(_loc2_ in Profile.ProfileList)
- {
- _loc3_++;
- (_loc4_ = new ProfileDisplay()).init(_loc2_);
- if(Profile.CurrentProfile == _loc2_)
- {
- _iCurrentProfileIndex = _loc3_;
- }
- setupItem(_loc4_);
- _loc1_.push(_loc4_);
- }
- trace("Profile list has " + _loc1_.length);
- return _loc1_;
- }
-
- protected function setupItem(param1:MovieClip) : void
- {
- param1.addEventListener(MouseEvent.MOUSE_OVER,onMouseEnter,false,0,true);
- param1.addEventListener(MouseEvent.MOUSE_OUT,onMouseLeave,false,0,true);
- param1.addEventListener(MouseEvent.CLICK,onMouseClick,false,0,true);
- }
-
- protected function onMouseClick(param1:MouseEvent) : void
- {
- var _loc2_:ProfileDisplay = null;
- _loc2_ = param1.currentTarget as ProfileDisplay;
- Profile.CurrentProfile = Profile.getProfile(_loc2_.ProfileName);
- Storage.getInstance().saveProfiles();
- _bCurrentProfile = false;
- onBack(new MouseEvent(""));
- }
-
- protected function swapItem(param1:DisplayObject, param2:DisplayObject) : void
- {
- addChildAt(param1,getChildIndex(param2));
- param1.x = param2.x + param2.width / 2;
- param1.y = param2.y + param2.height / 2;
- removeChild(param2);
- }
-
- protected function rebuildList() : void
- {
- _componentscroller.setItems(buildProfileLists());
- _componentscroller.update();
- }
-
- protected function onDeleteSlot(param1:MouseEvent) : void
- {
- var _loc2_:ProfileDisplay = null;
- var _loc3_:ProfileDeleteForm = null;
- _loc2_ = null;
- if(param1.currentTarget == _bDeleteSlot0)
- {
- _loc2_ = _componentscroller.getItemAtSlot(0) as ProfileDisplay;
- slotnumberIndex = 0;
- }
- else if(param1.currentTarget == _bDeleteSlot1)
- {
- _loc2_ = _componentscroller.getItemAtSlot(1) as ProfileDisplay;
- slotnumberIndex = 1;
- }
- if(_loc2_ != null)
- {
- _loc3_ = new ProfileDeleteForm();
- if(_loc2_.ProfileName == Profile.CurrentProfile.Name)
- {
- _bCurrentProfile = true;
- }
- _loc3_.init(_loc2_.ProfileName);
- setForm(_loc3_);
- }
- }
-
- protected function onUpdated(param1:Event) : void
- {
- var _loc2_:ProfileDisplay = null;
- var _loc3_:int = 0;
- _loc2_ = null;
- _loc3_ = 0;
- while(_loc3_ < 2)
- {
- _loc2_ = _componentscroller.getItemAtSlot(_loc3_) as ProfileDisplay;
- if(_loc2_ != null)
- {
- getChildByName("_bDeleteSlot" + _loc3_).visible = true;
- }
- else
- {
- getChildByName("_bDeleteSlot" + _loc3_).visible = false;
- }
- getChildByName("_tfDeleteSlot" + _loc3_).visible = getChildByName("_bDeleteSlot" + _loc3_).visible;
- _loc3_++;
- }
- }
-
- protected function onCreateClicked(param1:MouseEvent) : void
- {
- setForm(new ProfileCreatePopupForm(),true);
- }
- }
- }
-